﻿using System;
using System.ComponentModel;


namespace AsynchRequest
{
    public abstract class Request
    {
        internal BackgroundWorker bgw = new BackgroundWorker();
        public Request(Action action)
        {
            bgw.WorkerSupportsCancellation = true;
            bgw.DoWork += new DoWorkEventHandler((s, ea) =>
            {
                BackgroundWorker lb = s as BackgroundWorker;
                if (lb.CancellationPending == true)
                    return;
                action();
            });
        }
    }
}
